home *** CD-ROM | disk | FTP | other *** search
/ SoundMaker 2003 (Professional Edition) / SoundMaker 2003 - Professional Edition.iso / midi tool / midioxse.exe / DATA.1 / dataloop.rex < prev    next >
OS/2 REXX Batch file  |  1999-03-27  |  1KB  |  55 lines

  1. /* REXX: Simple MIDI output loop */
  2. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  3. call SysLoadFuncs 
  4.  
  5. qName = MOXGetQueueName()
  6. oldq  = RxQueue( 'Set', qName )
  7.  
  8. /* MIDI-OX creates a semaphore with same name as queue */
  9. sem = SysOpenEventSem( qName )
  10. if sem = 0 then
  11.    running = 0
  12. else
  13.    running = 1
  14.  
  15. do while running
  16.    do while Queued() <> 0
  17.       pull timestamp status data1 data2
  18.       if timestamp = 'END_DATA' 
  19.       then do
  20.          running = 0
  21.          leave
  22.       end
  23.  
  24.       /* leave on a high note */
  25.       if data1 = 96 & status = 144
  26.       then do
  27.          running = 0
  28.          leave
  29.       end
  30.            
  31.       /* ... do any processing.  Then ... */
  32.       if status = 144 then
  33.          status = 145
  34.  
  35.       ret = MOXOutputMidi( status, data1, data2 )
  36.       if ret <> 0 
  37.       then do
  38.           msg = "Error code: " || ret
  39.          call RxMessageBox msg, '', 'OK', 'STOP'  
  40.       end
  41.    end
  42.  
  43.    if running 
  44.    then do
  45.       /* queue is empty: you could do other processing here */       
  46.       ret = SysWaitEventSem( sem )
  47.       if ret <> 0 then
  48.          running = 0
  49.       
  50.    end
  51. end
  52.  
  53. call SysDropFuncs 
  54. exit
  55.